/* 
This do file counts the number of solar installations in each U.S. zip code.

NOTES: All directories and paths should be set in the main "Create_Number_Systems_Files.do" file.

*/

clear all

use `"${data_path}/TTSXI_EOY2017.dta"'

gen num_systems=1

drop if missing(zipcode)

drop if zipcode==-9999

*drop year
*gen int year = real(substr(date_installed,-4,.))
gen int year = real(substr(installationdate,-4,.))

drop if year !=2016 & year !=2017

*drop unnecessary variables in order to append to OpenPV dataset
drop dataprovider systemidfromdataprovider systemidtrackingthesun installationdate systemsize totalinstalledprice appraisedvalueflag salestaxcost rebateorgrant performancebasedincentiveannualp performancebasedincentivesdurati feedintariffannualpayment feedintariffduration customersegment newconstruction tracking trackingtype groundmounted batterysystem city county utilityserviceterritory thirdpartyowned installername selfinstalled azimuth1 azimuth2 azimuth3 tilt1 tilt2 tilt3 modulemanufacturer1 modulemodel1 modulemanufacturer2 modulemodel2 modulemanufacturer3 modulemodel3 additionalmodulemodel moduletechnology1 moduletechnology2 moduletechnology3 bipvmodule1 bipvmodule2 bipvmodule3 moduleefficiency1 moduleefficiency2 moduleefficiency3 invertermanufacturer1 invertermodel1 inverterquantity1 invertermanufacturer2 invertermodel2 inverterquantity2 invertermanufacturer3 invertermodel3 inverterquantity3 additionalinvertermodel microinverter1 microinverter2 microinverter3 dcoptimizer

save `"${data_intermediate}/NumberSystems_TTSXI_2016-2017.dta"', replace
